home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / PROGS / ADVANCED / SGIFLAG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  2.0 KB  |  68 lines

  1. /* 
  2.  *   sgiflag.h
  3.  *
  4.  */
  5.  
  6. /* useful for lmdef, nurbssurface, nurbscurve, and more */
  7. #define ELEMENTS(x)    (sizeof(x)/sizeof(x[0]))
  8.  
  9. /* Define nurbs surface properties */
  10. #define S_NUMPOINTS    4
  11. #define S_ORDER        4   /* cubic, degree 3 */
  12. #define S_NUMKNOTS    (S_NUMPOINTS + S_ORDER)
  13. #define S_NUMCOORDS    3
  14.  
  15. #define T_NUMPOINTS 4
  16. #define T_ORDER        4 
  17. #define T_NUMKNOTS    (T_NUMPOINTS + T_ORDER)
  18. #define T_NUMCOORDS    3
  19.  
  20. typedef GLfloat Knot;
  21. typedef GLfloat Point[3];
  22. typedef GLfloat TrimPoint[2];
  23.  
  24. /* Trimming curves are either piecewise linear or nurbscurve */
  25. enum TrimType {PWL, CURVE};
  26.  
  27.  
  28. /* A trimming curve is made up of one or more trimming pieces.
  29.  * A trimming piece may be of PWL or CURVE. If a trim piece is PWL,
  30.  * it has at least two trim points, with each trim point composing
  31.  * the endpoints of the line segments. If a trim piece is CURVE, it
  32.  * has four trim points defining the cubic bezier trim.
  33.  */
  34.  
  35. #define MAX_PIECES 20
  36.  
  37. struct TrimPieceStruct {
  38.     enum TrimType type;             /* type of the trim              */
  39.     int points;                     /* # of points in the trim piece */
  40.     TrimPoint point[MAX_PIECES];    /* pointer to first trim point   */
  41. };
  42. typedef struct TrimPieceStruct TrimPiece;
  43.  
  44. struct TrimCurveStruct {
  45.     int pieces;
  46.     TrimPiece *trim;
  47. };
  48. typedef struct TrimCurveStruct TrimCurve;
  49.  
  50.  
  51. struct teststruct {
  52.     int a, b, c[2];
  53. };
  54. typedef struct teststruct Test;
  55.  
  56. /* function prototypes */
  57. static void interp(TrimPoint a, TrimPoint b, GLfloat d, TrimPoint result);
  58. static void join_trims(TrimPiece *trim1, TrimPiece *trim2, GLfloat radius);
  59. static void translate_trim(TrimPiece *trim, GLfloat tx, GLfloat ty);
  60. static void scale_trim(TrimPiece *trim, GLfloat sx, GLfloat sy);
  61. static void rotate_trim(TrimPiece *trim, GLfloat angle);
  62. static void copy_path(TrimCurve *src, TrimCurve **dst);
  63. static void init_trims(void);
  64. static void initialize(void);
  65. static void draw_nurb(GLboolean);
  66. static void draw_hull(Point cpoints[S_NUMPOINTS][T_NUMPOINTS]);
  67. static void dotrim(TrimCurve *curve);
  68.